<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User_model extends AppModel {
    var $_primary_key = ADMIN_TBL_ADMIN_ID;
    var $_tablename = ADMIN_TBL;
    var $_mapping = array(
                           array('admin_id' => ADMIN_TBL_ADMIN_ID),
                           array('admin_login' => ADMIN_TBL_ADMIN_LOGIN),
                           array('admin_pw' => ADMIN_TBL_ADMIN_PW),
                            );														

    var $_cache = 'users_cache';
    var $_sort_field = 'admin_login';
    var $_sort_type = 0;
    public function User_model($id = NULL){
        parent::AppModel($id);
    }
	function get_lists($limit = NULL, $offset = NULL, $order_by = NULL, $order_type=0){
        //$conditions = array(USER_FRANCHISE_ID => $this->franchise_id);
		$conditions = array();
        return parent::get_lists($conditions, $limit, $offset, $order_by, $order_type);
    }
	
    function save($data, $user_id = NULL){
        if(is_null($user_id)){            
            $this->db->set($data);
            return $this->db->insert($this->_tablename);
        }else{
            $this->db->set($data);
            $this->db->where($this->_primary_key, $user_id);
            return $this->db->update($this->_tablename);
        }
    }
	function check_user_name($user_id=NULL, $user_name){
        $conditions = array(ADMIN_TBL_ADMIN_LOGIN=>$user_name);		
        if(!is_null($user_id))
            $this->db->where($this->_primary_key.' <> ', $user_id);
        return $this->db->get_where($this->_tablename, $conditions)->num_rows();
    }
	
    
}

?>